package com.framework.modules.sys.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.common.utils.PageUtils;
import com.framework.common.utils.Query;

import com.framework.modules.sys.dao.SysRegionAreaDao;
import com.framework.modules.sys.entity.SysRegionAreaEntity;
import com.framework.modules.sys.service.SysRegionAreaService;


@Service("sysRegionAreaService")
public class SysRegionAreaServiceImpl extends ServiceImpl<SysRegionAreaDao, SysRegionAreaEntity> implements SysRegionAreaService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<SysRegionAreaEntity> page = this.selectPage(
                new Query<SysRegionAreaEntity>(params).getPage(),
                new EntityWrapper<SysRegionAreaEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public String getRegionAreaDetail(Integer id) {
        String regionAreaDetail="";
        for(int i=0;i<3&&id>0;i++){
            SysRegionAreaEntity sysRegionAreaEntity1=this.selectById(id);
            if(i==0){
                regionAreaDetail= sysRegionAreaEntity1.getExtName();
            }else{
                regionAreaDetail=sysRegionAreaEntity1.getExtName()+"·"+regionAreaDetail;
            }
            id=sysRegionAreaEntity1.getPid();
        }
        return regionAreaDetail;
    }

    @Override
    public List<Map<String, Object>> getAllRegionList() {
        return this.baseMapper.getAllRegionList();
    }

    @Override
    public List<Map<String, Object>> getRegionListByPid(Integer pid) {
        return this.baseMapper.getRegionListByPid(pid);
    }


}
